/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Clases;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pablo
 */
@Entity
@Table(catalog = "Corrector_URJC", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"),
    @NamedQuery(name = "Curso.findByIdCurso", query = "SELECT c FROM Curso c WHERE c.idCurso = :idCurso"),
    @NamedQuery(name = "Curso.findByCurso", query = "SELECT c FROM Curso c WHERE c.curso = :curso"),
    @NamedQuery(name = "Curso.findByAsignatura", query = "SELECT c FROM Curso c WHERE c.asignatura = :asignatura")})
public class Curso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idCurso;
    private Integer curso;
    @Size(max = 50)
    @Column(length = 50)
    private String asignatura;
    @OneToMany(mappedBy = "idCursoFK")
    private Collection<CursoPractica> cursoPracticaCollection;
    @OneToMany(mappedBy = "idCursoFK")
    private Collection<UsuarioCurso> usuarioCursoCollection;

    public Curso() {
    }

    public Curso(Integer idCurso) {
        this.idCurso = idCurso;
    }

    public Integer getIdCurso() {
        return idCurso;
    }

    public void setIdCurso(Integer idCurso) {
        this.idCurso = idCurso;
    }

    public Integer getCurso() {
        return curso;
    }

    public void setCurso(Integer curso) {
        this.curso = curso;
    }

    public String getAsignatura() {
        return asignatura;
    }

    public void setAsignatura(String asignatura) {
        this.asignatura = asignatura;
    }

    @XmlTransient
    public Collection<CursoPractica> getCursoPracticaCollection() {
        return cursoPracticaCollection;
    }

    public void setCursoPracticaCollection(Collection<CursoPractica> cursoPracticaCollection) {
        this.cursoPracticaCollection = cursoPracticaCollection;
    }

    @XmlTransient
    public Collection<UsuarioCurso> getUsuarioCursoCollection() {
        return usuarioCursoCollection;
    }

    public void setUsuarioCursoCollection(Collection<UsuarioCurso> usuarioCursoCollection) {
        this.usuarioCursoCollection = usuarioCursoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCurso != null ? idCurso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Curso)) {
            return false;
        }
        Curso other = (Curso) object;
        if ((this.idCurso == null && other.idCurso != null) || (this.idCurso != null && !this.idCurso.equals(other.idCurso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return curso + "º- " + asignatura;
    }
    
}
